package com.dinzeer.resonantisshelomoh.se;






import com.dinzeer.legendreliclib.lib.compat.slashblade.SwordRainGenerator;
import com.dinzeer.legendreliclib.lib.compat.slashblade.entity.swordrain.BaseSwordRainEntity;
import com.dinzeer.legendreliclib.lib.util.slashblade.SlashBladeUtil;
import com.dinzeer.resonantisshelomoh.regsiter.RSSpecialEffectsRegistry;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.capability.slashblade.ISlashBladeState;
import mods.flammpfeil.slashblade.entity.EntityAbstractSummonedSword;
import mods.flammpfeil.slashblade.event.SlashBladeEvent;
import mods.flammpfeil.slashblade.registry.specialeffects.SpecialEffect;
import mods.flammpfeil.slashblade.slasharts.Drive;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;

@Mod.EventBusSubscriber
public class SE47 extends SpecialEffect {
    public SE47() {
        super(47);
    }
    @SubscribeEvent
    public static void onDoingSlash(SlashBladeEvent.DoSlashEvent event) {

        ISlashBladeState state = event.getSlashBladeState();
        if (state.hasSpecialEffect(RSSpecialEffectsRegistry.CompassionforTorture.getId())) {
            if (!(event.getUser() instanceof Player)) {
                return;
            }

            Player player = (Player)event.getUser();
            int level = player.experienceLevel;
            if (SpecialEffect.isEffective(RSSpecialEffectsRegistry.CompassionforTorture.get(), level)) {//血狐的se

             List<BaseSwordRainEntity> a =SwordRainGenerator.generateFivePointSwordRain(event.getUser(), event.getUser().level(),1);
             int i=0;
             for (BaseSwordRainEntity e : a){
                 if (!(i==2||i==3)){
                     e.discard();
                 }
                 i++;
             }


                Drive.doSlash(player,event.getRoll(),20,Vec3.ZERO, true, event.getDamage(), 2f);
            }





        }
        if (state.hasSpecialEffect(RSSpecialEffectsRegistry.Anuntraceablehope.getId())) {
            if (!(event.getUser() instanceof Player)) {
                return;
            }//写血狐se

            Player player = (Player)event.getUser();
            RandomSource random = player.getRandom();
            int level = player.experienceLevel;
            if (SpecialEffect.isEffective(RSSpecialEffectsRegistry.Anuntraceablehope.get(), level)) {//血狐的se
                Drive.doSlash(player,event.getRoll(),20,Vec3.ZERO, true, event.getDamage()+0.2, 2f);



            }




        }
    }

}
